<?php
/**
 * Notes:
 * User: wudg <544038230@qq.com>
 * Date: 2025/3/31 13:59
 */

namespace App\Components\Logs;


use App\Components\Logs\User\UserLoginLog;
use Hyperf\AsyncQueue\Driver\DriverFactory;
use Psr\Container\ContainerInterface;

class LogImpl
{

    /**
     * @var \Hyperf\AsyncQueue\Driver\DriverInterface
     */
    protected $logInterface;

    public function __construct(ContainerInterface $container)
    {
        $this->logInterface = $container->get(DriverFactory::class)->get('logQueue');
    }


    /**
     * 登录日志
     * @param array $saveData
     * @param int $delay 写入日志延迟时间
     * @return bool
     */
    public function saveLoginLog(array $saveData, int $delay = 1)
    {
        return $this->logInterface->push(new UserLoginLog($saveData),$delay);
    }
}